#pragma once
#ifdef LIT_OGRE_SUPPORT

#ifndef __LIT__SCENE__LOADER__INCLUDED__HH__
#define __LIT__SCENE__LOADER__INCLUDED__HH__
 
// Includes
#include <OgreString.h>
#include <OgreVector3.h>
#include <OgreQuaternion.h>
#include <vector>

#include <LitPrerequisites.h>
#include <OgreDataStream.h>
 
// Forward declarations
class TiXmlElement;
 
namespace Ogre
{
	// Forward declarations
	class SceneManager;
	class SceneNode;
 
	class LIT_API nodeProperty
	{
	public:
		Ogre::String nodeName;
		Ogre::String propertyNm;
		Ogre::String valueName;
		Ogre::String typeName;
 
		nodeProperty(const Ogre::String &node, const Ogre::String &propertyName, const Ogre::String &value, const Ogre::String &type)
			: nodeName(node), propertyNm(propertyName), valueName(value), typeName(type) {}
	};
 
	class LIT_API DotSceneLoader
	{
	public:
		DotSceneLoader() : mSceneMgr(0) {}
		virtual ~DotSceneLoader() {}
 
		bool parseDotScene(const Ogre::String &SceneName, const Ogre::String &groupName, Ogre::SceneManager *yourSceneMgr, Ogre::SceneNode *pAttachNode = NULL, const Ogre::String &sPrependNode = "");
		bool parseDotSceneStream(Ogre::DataStreamPtr&stream, const Ogre::String &groupName, Ogre::SceneManager *yourSceneMgr, Ogre::SceneNode *pAttachNode = NULL, const Ogre::String &sPrependNode = "");
		Ogre::String getProperty(const Ogre::String &ndNm, const Ogre::String &prop);
 
		std::vector<nodeProperty> nodeProperties;
		std::vector<Ogre::String> staticObjects;
		std::vector<Ogre::String> dynamicObjects;
 
		String lastError() const{ return mLastErr; }
	protected:
		String mLastErr;

		void processScene(TiXmlElement *XMLRoot);
 
		void processNodes(TiXmlElement *XMLNode);
		void processExternals(TiXmlElement *XMLNode);
		void processEnvironment(TiXmlElement *XMLNode);
		void processTerrain(TiXmlElement *XMLNode);
		void processUserDataReference(TiXmlElement *XMLNode, Ogre::SceneNode *pParent = 0);
		void processUserDataReference(TiXmlElement *XMLNode, Ogre::Entity *pEntity);
		void processOctree(TiXmlElement *XMLNode);
		void processLight(TiXmlElement *XMLNode, SceneNode *pParent = 0);
		void processCamera(TiXmlElement *XMLNode, SceneNode *pParent = 0);
 
		void processNode(TiXmlElement *XMLNode, SceneNode *pParent = 0);
		void processLookTarget(TiXmlElement *XMLNode, SceneNode *pParent);
		void processTrackTarget(TiXmlElement *XMLNode, SceneNode *pParent);
		void processEntity(TiXmlElement *XMLNode, SceneNode *pParent);
		void processParticleSystem(TiXmlElement *XMLNode, SceneNode *pParent);
		void processBillboardSet(TiXmlElement *XMLNode, SceneNode *pParent);
		void processPlane(TiXmlElement *XMLNode, SceneNode *pParent);
 
		void processFog(TiXmlElement *XMLNode);
		void processSkyBox(TiXmlElement *XMLNode);
		void processSkyDome(TiXmlElement *XMLNode);
		void processSkyPlane(TiXmlElement *XMLNode);
		void processClipping(TiXmlElement *XMLNode);
 
		void processLightRange(TiXmlElement *XMLNode, Light *pLight);
		void processLightAttenuation(TiXmlElement *XMLNode, Light *pLight);
 
		String getAttrib(TiXmlElement *XMLNode, const String &parameter, const String &defaultValue = "");
		Real getAttribReal(TiXmlElement *XMLNode, const String &parameter, Real defaultValue = 0);
		bool getAttribBool(TiXmlElement *XMLNode, const String &parameter, bool defaultValue = false);
 
		Vector3 parseVector3(TiXmlElement *XMLNode);
		Quaternion parseQuaternion(TiXmlElement *XMLNode);
		ColourValue parseColour(TiXmlElement *XMLNode);
 
 
		SceneManager *mSceneMgr;
		SceneNode *mAttachNode;
		Ogre::String m_sGroupName;
		Ogre::String m_sPrependNode;
	};
};

#endif

#endif // IF DEFINED LIT_OGRE_SUPPORT